Eclipse Platform
Pre-release 3.0

org.eclipse.jface.text.source
Interface ITagHandler


public interface ITagHandler

A tag handler is responsible to - handle the attributes for the tags it supports - translate the tag sequence including attributes to another language - back-translate relative line offsets.

Tag handlers are used by translators via tag handler factories.

XXX: This is work in progress and can change anytime until API for 3.0 is frozen.

Since:
3.0
See Also:
ITranslator, ITagHandlerFactory

Method Summary
 void addAttribute(String name, String value, int sourceLineNumber)
          Adds an attribute to this tag handler.
 int backTranslateOffsetInLine(String sourceLine, String translatedLine, int offsetInTranslatedLine)
          Computes the offset in the source line that corresponds to the given offset in the translated line.
 boolean canHandleTag(String tag)
          Tells whether this handler can handle the given tag.
 boolean canHandleText(String text)
          Tells whether this handler can handle the given text.
 void processEndTag(ITranslatorResultCollector resultCollector, int sourceLineNumber)
          Writes the tag and line mapping information to the given translator result collector.
 void reset(String tag)
          Resets this handler and sets the current tag to the given tag.
 

Method Detail

canHandleTag

public boolean canHandleTag(String tag)
Tells whether this handler can handle the given tag.

Parameters:
tag - the tag to check
Returns:
true if this handler handles the given tag

canHandleText

public boolean canHandleText(String text)
Tells whether this handler can handle the given text. Most likely the handler will check if the text contains a tag that he can handle.

Returns:
true if this handler handles the given text

addAttribute

public void addAttribute(String name,
                         String value,
                         int sourceLineNumber)
Adds an attribute to this tag handler.

Parameters:
name - the name of the attribute
value - the attribute value
sourceLineNumber - the line number of the attribute in the source or -1 if unknown

reset

public void reset(String tag)
Resets this handler and sets the current tag to the given tag. A handler can handle more than one tag but only one tag at a time.

Resetting the handler clears the attributes.

Parameters:
tag - the tag to check
Returns:
true if this handler handles the given tag

processEndTag

public void processEndTag(ITranslatorResultCollector resultCollector,
                          int sourceLineNumber)
                   throws IOException
Writes the tag and line mapping information to the given translator result collector.

Parameters:
resultCollector - the translator's result collector
sourceLineNumber - the line number of the attribute in the source or -1 if unknown
Throws:
IOException

backTranslateOffsetInLine

public int backTranslateOffsetInLine(String sourceLine,
                                     String translatedLine,
                                     int offsetInTranslatedLine)
Computes the offset in the source line that corresponds to the given offset in the translated line.

Parameters:
translatedLine - the translated line
offsetInTranslatedLine - the offset in the translated line
Returns:
the offset in the source line or -1 if it was not possible to compute the offset

Eclipse Platform
Pre-release 3.0

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.